{extend name='common/content' /}

{block name="button"}
<div class="nowrap pull-right" style="margin-top:10px">
    <button data-update data-field='delete' data-action='{:url("$classuri/del")}'
            class='layui-btn layui-btn-small layui-btn-danger'><i class='fa fa-remove'></i> 删除订单
    </button>
</div>
{/block}

{block name="content"}

<!-- 表单搜索 开始 -->
<form class="animated form-search" action="__SELF__" onsubmit="return false" method="get">

    <div class="row">
        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="phone" value="{$Think.get.phone|default=''}" placeholder="客户手机号码"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="buyer_name" value="{$Think.get.buyer_name|default=''}" placeholder="客户姓名"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-3">
            <div class="form-group">
                <input type="text" name="dead_id_card" value="{$Think.get.dead_id_card|default=''}" placeholder="墓穴证编号"
                       class="input-sm form-control">
            </div>
        </div>

        <div class="col-xs-1">
            <div class="form-group">
                <button type="submit" class="btn btn-sm btn-white"><i class="fa fa-search"></i> 搜索</button>
            </div>
        </div>
    </div>
</form>
<!-- 表单搜索 结束 -->

<form onsubmit="return false;" data-auto="" method="POST">
    <input type="hidden" value="resort" name="action"/>
    <div class="layui-form">
        <table class="table table-hover">
            <thead>
            <tr>
                <th>
                    <input data-none-auto="" data-check-target='.list-check-box' lay-skin="primary" lay-filter="allChoose" type="checkbox">
                </th>
                <th class='text-center'>订单号</th>
                <th class='text-center'>公墓编号</th>
                <!--<th class='text-center'>云纪念馆编号</th>-->
                <th class='text-center'>成交价</th>
                <th class='text-center'>客户姓名</th>
                <th class='text-center'>销售人员</th>
                <th class='text-center'>下单时间</th>
                <th class='text-center'>订单状态</th>
                <th class='text-center'>操作</th>
            </tr>
            </thead>
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td>
                    <input class="list-check-box" value='{$vo.order_id}' lay-skin="primary" type="checkbox">
                </td>
                <td class='text-center'>{$vo.order_sn}</td>
                <td class='text-center'>{$vo.cemetery_sn}</td>
                <!--<td class='text-center'>{$vo.hall_sn}</td>-->
                <td class='text-center'>{$vo.order_amount}</td>
                <td class='text-center'>{$vo.buyer_name_1}</td>
                <th class='text-center'>{$vo.seller}</th>
                <td class='text-center'>{$vo.deal_time}</td>
                <td class='text-center'>
                    {if $vo.order_state eq 0}
                    <span>已取消</span>
                    {elseif $vo.order_state eq 20}
                    <span style="color:#cc0000">待付款</span>
                    {elseif $vo.order_state eq 21}
                    <span style="color:#090">已付款</span>
                    {/if}
                </td>
                <td class='text-center nowrap'>

                    <div class="layui-btn-group">
                        {if b_auth("$classuri/orderGoods")}
                        <button type="button" data-modal='{:url("$classuri/orderGoods")}?order_id={$vo.order_id}' data-title="订单详情" class="layui-btn layui-btn-primary layui-btn-small">查看订单</button>
                        {/if}
                    </div>
                </td>
            </tr>
            {/foreach}

            <input type="hidden" name="image" onchange="add_img(this.value)" value="" class="layui-input">
            </tbody>
        </table>
    </div>
    {if isset($page)}<p>{$page}</p>{/if}
</form>

<script>window.form.render();</script>
<script>
    layui.use('form', function(){
        var $ = layui.jquery, form = layui.form;

        //全选
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('table').find('tbody input[type="checkbox"]');
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });

    });
</script>


<script>

    var orderId = '';
    $(".upload-hetong").click(function () {
        orderId = $(this).attr('data-id');
    })

    function add_img(value) {
        $.post('{:url("$classuri/addcontract")}',{order_id:orderId, value:value},function (result) {
            if (result){
                layer.msg('上传成功！')
            }else{
                layer.msg('上传失败！')
            }
        })
    }
</script>

{/block}